package com.picture.download.setup;
import com.picture.download.Settings;
import com.picture.download.entity.Category;
import com.picture.download.entity.Images;
import org.nutz.dao.Dao;
import org.nutz.log.Logs;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
/**
 * Created by chenjidong on 2015/4/22.
 */
public class AppSetup implements ServletContextListener {
    private static final org.nutz.log.Log log = Logs.getLog(AppSetup.class);
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        log.info("-------------------------app init-----------------");
        Settings.path = servletContextEvent.getServletContext().getRealPath("/WEB-INF/classes/dao.js");
        Dao dao = Settings.getDao();

        dao.create(Images.class, false);
        dao.create(Category.class, false);
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        log.info("-------------------------app Destroyed-----------------");
    }
}
